#!/bin/bash

echo "guess a number game start! "

echo "name: HUANGXIAOLEI, id: 24055060326"

NUM1=$(( RANDOM % 100 + 1 ))

START=1
MAX=7

while [ $START -le $MAX ]; do
  
  read -p "$START/$MAX: Please input a num(1-100): " NUM2
  
  if [ $NUM2 -gt $NUM1 ]; then
    echo "The number you entered is too big!"
  elif [ $NUM2 -lt $NUM1 ]; then
    echo "The number you entered is too small!"
  else
    echo "Congratulations! You guessed it right!"
    exit 0
  fi
  
  START=$(( START + 1 ))
done

echo "You lost! The correct number was: $NUM1"